import Vue from 'vue'
import Router from 'vue-router'


// 1. helloword 页面
import login from '@/components/login'
import register from '@/components/register'
import daohang from '@/layout/daohang'
import ant_show from '@/components/ant_show'
import ant_put from '@/components/ant_put'
import ant_del from '@/components/ant_del'
import ant_add from '@/components/ant_add'
import ant_user from '@/components/ant_user'
import zanshi from '@/components/zanshi'
import ding_login from '@/components/ding_login'
import ant_putquan from '@/components/ant_putquan'
import ant_showquan from '@/components/ant_showquan'
import order_ledger from '@/components/myWorker/order_ledger'
import reply from '@/components/myWorker/Reply'
import leave from '@/components/myWorker/Leave'

import axios from 'axios'
Vue.use(Router)

export default new Router({
  mode:'history',
  routes: [
    {
      path: '/register',
      name: 'register',
      component: register
    },
    {
      path: '/login',
      name: 'login',
      component: login
      
    },
    {
      path: '/zanshi',
      name: 'zanshi',
      component: zanshi
    },
    {
      path: '/',
      name: 'daohang',
      component: daohang,
      beforeEnter: (to, from, next) => {
        if (sessionStorage.getItem("username")) {
          console.log("登录了");
          next();
        } else {
          next("/login");
        }
      },
      children:[
        
            {
            path: '/ant_add',
            name: 'ant_add',
            component: ant_add,
            },
            
            {
            path: '/ant_show',
            name: 'ant_show',
            component: ant_show,

            },
            
            {
              path: '/ant_put',
              name: 'ant_put',
              component: ant_put,

            },
            
            {
              path: '/ant_del',
              name: 'ant_del',
              component: ant_del,

            },
            
            {
              path: '/ant_user',
              name: 'ant_user',
              component: ant_user,

            },
            {
              path: '/ding_login',
              name: 'ding_login',
              component: ding_login,

            },
            {
              path: '/ant_putquan',
              name: 'ant_putquan',
              component: ant_putquan,

            },
            {
              path: '/ant_showquan',
              name: 'ant_showquan',
              component: ant_showquan,

            },
            
            {
              path: '/order_ledger',
              name: 'order_ledger',
              component: order_ledger
            },
            {
              path: '/reply',
              name: 'reply',
              component: reply
            },
            {
              path: '/leave',
              name: 'leave',
              component: leave
            },
            
      ]
    },

    
  ]
})


